<?php
/*
 CREATE TABLE route (
	module varchar not null, -- reference module(name) 
	subject varchar not null,      -- string: url path matching for
	controller varchar not null,   -- string: controller name
	action varchar not null,       -- string: action name
	defvars hstore,               -- key: value, default values for request variables
	requires hstore,
	map hstore,                   -- key: value, map for numbered matches with regex
	reverse varchar,               -- string: used with url view helper for assemling url's
	type integer not null,                       -- type: 1) static 2) dynamic 3) regex
	PRIMARY KEY(id)
) inherits (object);


=== Zend_Controller_Router_Route_Static ===

$route = new Zend_Controller_Router_Route_Static(
    'login',
    array(
    	'controller' => 'auth',
    	'action' => 'login'
    )
);

=== Zend_Controller_Router_Route_Regex ===

$route = new Zend_Controller_Router_Route_Regex(
    'blog/archive/(\d+)-(.+)\.html',
    array(
        'controller' => 'blog',
        'action'     => 'view'
    ),
    array(
        1 => 'id',
        2 => 'description'
    ),
    'blog/archive/%d-%s.html'
);

 */
class Agitum_Orm_Route extends Agitum_Orm_Object
{
    protected function init() 
    {
        parent::init();
        
        $this->name = 'route';
        $this->title = 'Маршрут';
        
        $this->schema['module'] = Agitum_Orm_Attribute::factory(
            Agitum_Orm_Attirbute_Type::String, 
            array(
                'name' => 'module',
                'title' => 'Модуль',
                'sortOrder' => '60'
            )
        );
        
        $this->schema['controller'] = Agitum_Orm_Attribute::factory(
            Agitum_Orm_Attirbute_Type::String, 
            array(
                'name' => 'controller',
                'title' => 'Контроллер',
                'sortOrder' => '70'
            )
        );
        
        $this->schema['action'] = Agitum_Orm_Attribute::factory(
            Agitum_Orm_Attirbute_Type::String, 
            array(
                'name' => 'action',
                'title' => 'Действие',
                'sortOrder' => '80'
            )
        );
        
        $this->schema['subject'] = Agitum_Orm_Attribute::factory(
            Agitum_Orm_Attirbute_Type::String, 
            array(
                'name' => 'subject',
                'title' => 'Шаблон URL',
                'sortOrder' => '90'
            )
        );
        
        $this->schema['defvars'] = Agitum_Orm_Attribute::factory(
            Agitum_Orm_Attirbute_Type::HStore, 
            array(
                'name' => 'defvars',
                'title' => 'Значения по-умолчанию',
                'sortOrder' => '100'
            )
        );
        
        $this->schema['requires'] = Agitum_Orm_Attribute::factory(
            Agitum_Orm_Attirbute_Type::HStore, 
            array(
                'name' => 'requires',
                'title' => 'Требования к переменным',
                'sortOrder' => '110'
            )
        );
        
        $this->schema['map'] = Agitum_Orm_Attribute::factory(
            Agitum_Orm_Attirbute_Type::HStore, 
            array(
                'name' => 'map',
                'title' => 'Соответсвтие перенным запроса',
                'sortOrder' => '120'
            )
        );
        
        $this->schema['reverse'] = Agitum_Orm_Attribute::factory(
            Agitum_Orm_Attirbute_Type::String, 
            array(
                'name' => 'reverse',
                'title' => 'Шаблон сборки URL',
                'sortOrder' => '130'
            )
        );
        
        $this->schema['type'] = Agitum_Orm_Attribute::factory(
            Agitum_Orm_Attirbute_Type::Integer, 
            array(
                'name' => 'type',
                'title' => 'Тип маршрутизатора',
                'sortOrder' => '140'
            )
        );
    }
}